package cn.edu.scau.cmi.yejiancong.factory.client;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import cn.edu.scau.cmi.yejiancong.abstractFactory.insurance.insurance;
import cn.edu.scau.cmi.yejiancong.factory.insurance.bodyinjurfactory;
import cn.edu.scau.cmi.yejiancong.factory.insurance.carBrokefactory;
import cn.edu.scau.cmi.yejiancong.factory.insurance.otherCasefactory;
import cn.edu.scau.cmi.yejiancong.factory.insurance.peopleDamgefactory;
import cn.edu.scau.cmi.yejiancong.factory.insurancefatory.insurancefactory;
import cn.edu.scau.cmi.yejiancong.simplefactory.man;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;

import javafx.scene.control.Label;

import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;

import javafx.scene.control.RadioButton;

import javafx.scene.layout.BorderPane;

import javafx.scene.control.ChoiceBox;

public class viewController {
	@FXML
	private AnchorPane apane;
	@FXML
	private TextArea information;
	@FXML
	private Label nameLaber;
	@FXML
	private Label numberLaber;
	
	@FXML
	private BorderPane paner;
	@FXML
	private ChoiceBox insure;
	@FXML
	private Button showBut1;
	

	@FXML
	public void initialize() {
		man yjc=new man();
		insurance insurance=null;
		
		
		
		nameLaber.setText(yjc.getName());
		numberLaber.setText(yjc.getNumber().toString());
		
		Image image =new Image(getClass().getResourceAsStream("yjc.jpg"));
		ImageView imageView = new ImageView();
		
		imageView.setImage(image);
		imageView.setFitHeight(100);
		imageView.setFitWidth(100);
		paner.setCenter(imageView);
		insure.setItems(FXCollections.observableArrayList(
			    "bodyInjur", "carBroke", "peopleDamge","otherCase"));
	}
	// Event Listener on Button[#showBut1].onAction
	@FXML
	public void show() {
			String insurancetype=(String) insure.getSelectionModel().getSelectedItem();
			insurancefactory insurancefactory=null;
			if(insurancetype.equals("bodyInjur")) {
				insurancefactory=new bodyinjurfactory();
				information.setText(insurancefactory.insurance().getinsurance().toString());
			}
			else if(insurancetype.equals("carBroke")) {
				insurancefactory=new carBrokefactory();
				information.setText(insurancefactory.insurance().getinsurance().toString());
			}
			else if(insurancetype.equals("peopleDamge")) {
				insurancefactory=new peopleDamgefactory();
				information.setText(insurancefactory.insurance().getinsurance().toString());
			}
			else if(insurancetype.equals("otherCase")) {
				insurancefactory=new otherCasefactory();
				information.setText(insurancefactory.insurance().getinsurance().toString());
			}
	}
}
